package com.spring5.learning.service;

import org.springframework.beans.factory.annotation.Lookup;
import org.springframework.stereotype.Component;

/**
 * @author xin
 * @version 1.0
 */
@Component
public abstract class AbstractCommandManager implements CommandManager {
    @Override
    public Object process(Object commandState) {
        Command command = createCommand();
        System.out.println(command);
        command.setState(commandState);
        return command.execute();
    }

    @Lookup
    protected abstract Command createCommand();
}
